import React, { createRef, PureComponent } from 'react'

export class App extends PureComponent {
  constructor() {
    super()
    this.inputRef = createRef()
  }
  componentDidMount () {
    this.inputRef.current.addEventListener('input', (event) => {
      console.log(event.target.value)
    })
  }
  handleSubmit() {
    console.log(this.inputRef.current.value)
  }
  render() {
    return (
      <div>
        <input type="text" ref={this.inputRef} defaultValue="hello" />
        <button onClick={() => this.handleSubmit()}>提交</button>
      </div>
    )
  }
}

export default App